package com.lytoyo.neihanduanzi.controller;

import com.lytoyo.neihanduanzi.aspect.Login;
import com.lytoyo.neihanduanzi.model.Result;
import com.lytoyo.neihanduanzi.service.UserAttentionService;
import com.lytoyo.neihanduanzi.utils.AuthContextHolder;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * Package:com.lytoyo.neihanduanzi.controller
 *
 * @ClassName:UserAttentionController
 * @Create:2025/4/29 10:27
 **/
@RestController
@RequestMapping("/attention")
public class UserAttentionController {
    @Resource
    private UserAttentionService userAttentionService;

    /**
     * 关注用户
     * @return
     */
    @Login
    @PostMapping("/add")
    public Result attentionAddUser(@RequestParam("userId")Long userId){
        Long fan = AuthContextHolder.getUserId();
        return this.userAttentionService.attention(userId,fan);
    }

    /**
     * 取消关注
     * @return
     */
    @Login
    @PostMapping("/sub")
    public Result attentionSubUser(@RequestParam("userId")Long userId){
        Long fan = AuthContextHolder.getUserId();
        return this.userAttentionService.subAttention(userId,fan);
    }

}
